package com.heriparid.fragmentinjection.controllers;

import javax.inject.Inject;
import javax.inject.Singleton;

import com.heriparid.fragmentinjection.annotations.ForApplicationContext;

import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.widget.Toast;

@Singleton
public class MainController {
	
	private final Handler mHandler;
	private final Context mContext;
	
	@Inject
	public MainController(Handler handler, @ForApplicationContext Context context) {
		mHandler = handler;
		mContext = context;
	}

	private static final String TAG = MainController.class.getSimpleName();
	
	public void onItemClicked(final int position){
		Log.v(TAG, String.format("Item at %d has been clicked", position));
		
		mHandler.post(new Runnable() {
			
			@Override
			public void run() {
				Toast.makeText(mContext, String.format("Item at %d has been clicked", position), Toast.LENGTH_SHORT).show();
			}
		});
	}
}
